From: Natalie Boehm Date: Thu, 28 Sep 2017 19:23:48 +0000 (-0400) Subject: add boolean to struct to support what crates is sending X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~6^2~29^2 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=8150b602ba8a90832d2dbb00545163b3efd064be;p=cargo.git add boolean to struct to support what crates is sending in case an old version of cargo is being used. the old version should be able to decode the boolean and ignore the string. --- diff --git a/src/cargo/ops/registry.rs b/src/cargo/ops/registry.rs index 72c41405b..42ff2f872 100644 --- a/src/cargo/ops/registry.rs +++ b/src/cargo/ops/registry.rs @@ -320,8 +320,6 @@ pub fn modify_owners(config: &Config, opts: &OwnersOptions) -> CargoResult<()> { if let Some(ref v) = opts.to_add { let v = v.iter().map(|s| &s[..]).collect::>(); - //config.shell().status("Owner", format!("adding {:?} to crate {}", - // v, name))?; let msg = registry.add_owners(&name, &v).map_err(|e| { CargoError::from(format!("failed to invite owners to crate {}: {}", name, e)) })?; diff --git a/src/crates-io/lib.rs b/src/crates-io/lib.rs index c2a845860..6caa46cf7 100644 --- a/src/crates-io/lib.rs +++ b/src/crates-io/lib.rs @@ -116,7 +116,7 @@ pub struct Warnings { } #[derive(Deserialize)] struct R { ok: bool } -#[derive(Deserialize)] struct OwnerResponse { ok: String } +#[derive(Deserialize)] struct OwnerResponse { ok: bool, msg: String } #[derive(Deserialize)] struct ApiErrorList { errors: Vec } #[derive(Deserialize)] struct ApiError { detail: String } #[derive(Serialize)] struct OwnersReq<'a> { users: &'a [&'a str] } @@ -142,14 +142,15 @@ impl Registry { let body = serde_json::to_string(&OwnersReq { users: owners })?; let body = self.put(format!("/crates/{}/owners", krate), body.as_bytes())?; - Ok(serde_json::from_str::(&body)?.ok) + assert!(serde_json::from_str::(&body)?.ok); + Ok(serde_json::from_str::(&body)?.msg) } pub fn remove_owners(&mut self, krate: &str, owners: &[&str]) -> Result<()> { let body = serde_json::to_string(&OwnersReq { users: owners })?; let body = self.delete(format!("/crates/{}/owners", krate), Some(body.as_bytes()))?; - serde_json::from_str::(&body)?; + assert!(serde_json::from_str::(&body)?.ok); Ok(()) }